
	 // EMERGENT GAME TECHNOLOGIES PROPRIETARY INFORMATION

// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Emergent Game Technologies and may not be copied
// or disclosed except in accordance with the terms of that agreement. Copyright
// (c) 1996-2008 Emergent Game Technologies. All Rights Reserved. Emergent Game
// Technologies, Chapel Hill, North Carolina 27517 http://www.emergent.net ;
// EMERGENT GAME TECHNOLOGIES PROPRIETARY INFORMATION This software is supplied
// under the terms of a license agreement or nondisclosure agreement with Emergent
// Game Technologies and may not be copied or disclosed except in accordance with
// the terms of that agreement. Copyright (c) 1996-2008 Emergent Game
// Technologies. All Rights Reserved. Emergent Game Technologies, Chapel Hill,
// North Carolina 27517 http://www.emergent.net
#pragma once

// Recording Macros Generated from MacroGenerator_Record.xls, do not modify here
// v ;
// Generated from MacroGenerator_Record.xls, do not modify here ^ required for
// setting constants. ;
// Playback Macros Generated from MacroGenerator_Playback.xls, do not modify here
// v ;
// Generated from MacroGenerator_Playback.xls, do not modify here ^ this is used
// primarily to read from memory buffer and play shader constant set calls. ;
// Get and Put macros
typedef UINT * LPUINT;
typedef D3DCAPS9	*LPD3DCAPS9;

// EMERGENT GAME TECHNOLOGIES PROPRIETARY INFORMATION This software is supplied
// under the terms of a license agreement or nondisclosure agreement with Emergent
// Game Technologies and may not be copied or disclosed except in accordance with
// the terms of that agreement. Copyright (c) 1996-2008 Emergent Game
// Technologies. All Rights Reserved. Emergent Game Technologies, Chapel Hill,
// North Carolina 27517 http://www.emergent.net
void				SetMemoryTrace(bool bval);
void				SetCommandBufferPlaybackAPITrace(bool bval);
void				SetCommandBufferRecordAPITrace(bool bval);

// This enumeration is used to index into the PlaybackNumberArgs table to obtain
// the number of
namespace			CBD3D_COMMANDS
{
enum
{
	NULLCALL					= 0xD3D00000,	// High value to catch command buffer errors
	QueryInterface,
	AddRef,
	Release,
	DrawPrimitive,
	DrawIndexedPrimitive,
	SetStreamSource,
	SetStreamSourceFreq,
	SetVertexDeclaration,
	SetIndices,
	TestCooperativeLevel,
	EvictManagedResources,
	BeginScene,
	EndScene,
	BeginStateBlock,
	SetCursorProperties,
	SetCursorPosition,
	SetDialogBoxMode,
	GetDeviceCaps,
	GetDisplayMode,
	GetCreationParameters,
	CreateAdditionalSwapChain,
	GetSwapChain,
	Reset,
	Present,
	GetBackBuffer,
	GetRasterStatus,
	SetGammaRamp,
	GetGammaRamp,
	CreateTexture,
	CreateVolumeTexture,
	CreateCubeTexture,
	CreateVertexBuffer,
	CreateIndexBuffer,
	CreateRenderTarget,
	CreateDepthStencilSurface,
	UpdateSurface,
	UpdateTexture,
	GetRenderTargetData,
	GetFrontBufferData,
	StretchRect,
	ColorFill,
	CreateOffscreenPlainSurface,
	SetRenderTarget,
	GetRenderTarget,
	SetDepthStencilSurface,
	GetDepthStencilSurface,
	Clear,
	SetTransform,
	GetTransform,
	MultiplyTransform,
	SetViewport,
	GetViewport,
	SetMaterial,
	GetMaterial,
	SetLight,
	GetLight,
	LightEnable,
	GetLightEnable,
	SetClipPlane,
	GetClipPlane,
	SetRenderState,
	GetRenderState,
	CreateStateBlock,
	EndStateBlock,
	SetClipStatus,
	GetClipStatus,
	GetTexture,
	SetTexture,
	GetTextureStageState,
	SetTextureStageState,
	GetSamplerState,
	SetSamplerState,
	ValidateDevice,
	SetPaletteEntries,
	GetPaletteEntries,
	SetCurrentTexturePalette,
	GetCurrentTexturePalette,
	SetScissorRect,
	GetScissorRect,
	SetSoftwareVertexProcessing,
	SetNPatchMode,
	DrawPrimitiveUP,
	DrawIndexedPrimitiveUP,
	ProcessVertices,
	CreateVertexDeclaration,
	GetVertexDeclaration,
	SetFVF,
	GetFVF,
	CreateVertexShader,
	SetVertexShader,
	GetVertexShader,
	SetVertexShaderConstantF,
	GetVertexShaderConstantF,
	SetVertexShaderConstantI,
	GetVertexShaderConstantI,
	SetVertexShaderConstantB,
	GetVertexShaderConstantB,
	GetStreamSource,
	GetStreamSourceFreq,
	GetIndices,
	CreatePixelShader,
	SetPixelShader,
	GetPixelShader,
	SetPixelShaderConstantF,
	GetPixelShaderConstantF,
	SetPixelShaderConstantI,
	GetPixelShaderConstantI,
	SetPixelShaderConstantB,
	GetPixelShaderConstantB,
	DrawRectPatch,
	DrawTriPatch,
	DeletePatch,
	CreateQuery,
	GetDirect3D,
	GetAvailableTextureMem,
	GetNumberOfSwapChains,
	ShowCursor,
	GetSoftwareVertexProcessing,
	GetNPatchMode
};
}
// disable type conversion errors
#pragma warning(disable : 4312)
#pragma warning(disable : 4311)
class	CBMemoryBuffer
{
/* ---------------------------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------------------------------- */
public:
	CBMemoryBuffer();
	void			ResetNext();
	void			GetCBMemory(DWORD * &pMem, UINT &iNumDWORDs);
	void			SetCBMemory(DWORD *pMem, UINT iNumDWORDs);

	// put or get DWORD sized tokens
	inline DWORD	DoGetDWORD();
	inline DWORD	*DoGetDWORDPTR();	// peek at the next token

	// memsize is size in bytes
	inline DWORD	*DoGetMem(DWORD memsize);
	static char		*strFuncNames[120];

	/* =================================================================================================================
	 =================================================================================================================== */
	static char *Index2FunctionName(unsigned int index)
	{
		return CBMemoryBuffer::strFuncNames[index - CBD3D_COMMANDS::NULLCALL];
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	template<class TYPE>
	void DoPutDWORD(TYPE val)
	{
		assert(sizeof(TYPE) <= sizeof(DWORD));
		assert(m_pNext >= m_pMem);
		assert(m_pNext < (m_pMem + m_iSize));
		*m_pNext = (DWORD) val;
		m_pNext++;
		;;
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	template<class TYPE>
	void DoPutMem(TYPE *val, DWORD memsize)
	{
		int memsize_in_DWORDs = (memsize + 3) / 4;	// Number of DWORDs required to store memsize, round up
		assert(m_pNext >= m_pMem);
		assert((m_pNext + memsize_in_DWORDs - 1) < (m_pMem + m_iSize));
		if(val == NULL)
			*m_pNext = 0;
		else
			*m_pNext = 1;
		m_pNext++;
		if(val != NULL)
		{
			memcpy((void *) m_pNext, (const void *) val, memsize);
			m_pNext += memsize_in_DWORDs;
		}

		;;
	}

	// =================================================================================================================
	//    types of size > DWORD
	// =================================================================================================================
	void GetDWORD(D3DCAPS9 **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(D3DCAPS9));
		*arg = reinterpret_cast < D3DCAPS9 * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DCAPS9 *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(D3DCAPS9));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DDEVICE_CREATION_PARAMETERS **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(D3DDEVICE_CREATION_PARAMETERS));
		*arg = reinterpret_cast < D3DDEVICE_CREATION_PARAMETERS * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DDEVICE_CREATION_PARAMETERS *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(D3DDEVICE_CREATION_PARAMETERS));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DPRESENT_PARAMETERS **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(D3DPRESENT_PARAMETERS));
		*arg = reinterpret_cast < D3DPRESENT_PARAMETERS * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DPRESENT_PARAMETERS *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(D3DPRESENT_PARAMETERS));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST RECT **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST RECT));
		*arg = reinterpret_cast < CONST RECT * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST RECT *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST RECT));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST RGNDATA **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST RGNDATA));
		*arg = reinterpret_cast < CONST RGNDATA * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST RGNDATA *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST RGNDATA));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST D3DGAMMARAMP **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST D3DGAMMARAMP));
		*arg = reinterpret_cast < CONST D3DGAMMARAMP * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST D3DGAMMARAMP *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST D3DGAMMARAMP));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DGAMMARAMP **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(D3DGAMMARAMP));
		*arg = reinterpret_cast < D3DGAMMARAMP * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DGAMMARAMP *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(D3DGAMMARAMP));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DRASTER_STATUS **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(D3DRASTER_STATUS));
		*arg = reinterpret_cast < D3DRASTER_STATUS * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DRASTER_STATUS *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(D3DRASTER_STATUS));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST POINT **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST POINT));
		*arg = reinterpret_cast < CONST POINT * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST POINT *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST POINT));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST D3DRECT **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST D3DRECT));
		*arg = reinterpret_cast < CONST D3DRECT * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST D3DRECT *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST D3DRECT));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST D3DMATRIX **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST D3DMATRIX));
		*arg = reinterpret_cast < CONST D3DMATRIX * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST D3DMATRIX *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST D3DMATRIX));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DMATRIX **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(D3DMATRIX));
		*arg = reinterpret_cast < D3DMATRIX * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DMATRIX *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(D3DMATRIX));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST D3DVIEWPORT9 **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST D3DVIEWPORT9));
		*arg = reinterpret_cast < CONST D3DVIEWPORT9 * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST D3DVIEWPORT9 *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST D3DVIEWPORT9));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DVIEWPORT9 **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(D3DVIEWPORT9));
		*arg = reinterpret_cast < D3DVIEWPORT9 * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DVIEWPORT9 *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(D3DVIEWPORT9));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST D3DMATERIAL9 **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST D3DMATERIAL9));
		*arg = reinterpret_cast < CONST D3DMATERIAL9 * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST D3DMATERIAL9 *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST D3DMATERIAL9));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DMATERIAL9 **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(D3DMATERIAL9));
		*arg = reinterpret_cast < D3DMATERIAL9 * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DMATERIAL9 *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(D3DMATERIAL9));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST D3DLIGHT9 **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST D3DLIGHT9));
		*arg = reinterpret_cast < CONST D3DLIGHT9 * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST D3DLIGHT9 *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST D3DLIGHT9));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DLIGHT9 **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(D3DLIGHT9));
		*arg = reinterpret_cast < D3DLIGHT9 * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DLIGHT9 *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(D3DLIGHT9));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST PALETTEENTRY **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST PALETTEENTRY));
		*arg = reinterpret_cast < CONST PALETTEENTRY * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST PALETTEENTRY *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST PALETTEENTRY));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(PALETTEENTRY **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(PALETTEENTRY));
		*arg = reinterpret_cast < PALETTEENTRY * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(PALETTEENTRY *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(PALETTEENTRY));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(RECT **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(RECT));
		*arg = reinterpret_cast < RECT * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(RECT *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(RECT));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST D3DVERTEXELEMENT9 **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST D3DVERTEXELEMENT9));
		*arg = reinterpret_cast < CONST D3DVERTEXELEMENT9 * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST D3DVERTEXELEMENT9 *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST D3DVERTEXELEMENT9));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST D3DCLIPSTATUS9 **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST D3DCLIPSTATUS9));
		*arg = reinterpret_cast < CONST D3DCLIPSTATUS9 * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST D3DCLIPSTATUS9 *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST D3DCLIPSTATUS9));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DCLIPSTATUS9 **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(D3DCLIPSTATUS9));
		*arg = reinterpret_cast < D3DCLIPSTATUS9 * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DCLIPSTATUS9 *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(D3DCLIPSTATUS9));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST D3DRECTPATCH_INFO **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST D3DRECTPATCH_INFO));
		*arg = reinterpret_cast < CONST D3DRECTPATCH_INFO * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST D3DRECTPATCH_INFO *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST D3DRECTPATCH_INFO));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST D3DTRIPATCH_INFO **arg)
	{
		DWORD	*temp = DoGetMem(sizeof(CONST D3DTRIPATCH_INFO));
		*arg = reinterpret_cast < CONST D3DTRIPATCH_INFO * > (temp);
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST D3DTRIPATCH_INFO *arg)
	{
		DoPutMem((DWORD *) arg, sizeof(CONST D3DTRIPATCH_INFO));
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DDISPLAYMODE **arg)
	{
		*arg = (D3DDISPLAYMODE *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DDISPLAYMODE *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(BOOL **arg)
	{
		*arg = (BOOL *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(BOOL *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST float **arg)
	{
		*arg = (CONST float *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST float *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(float **arg)
	{
		*arg = (float *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(float *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(DWORD **arg)
	{
		*arg = (DWORD *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(DWORD *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST void **arg)
	{
		*arg = (CONST void *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST void *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST DWORD **arg)
	{
		*arg = (CONST DWORD *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST DWORD *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(CONST int **arg)
	{
		*arg = (CONST int *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(CONST int *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(LPUINT *arg)
	{
		*arg = (LPUINT) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(LPUINT arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	// =================================================================================================================
	//    types that can be cast as DWORDs
	// =================================================================================================================
	void GetDWORD(void ***arg)
	{
		*arg = (void **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(void **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DPRIMITIVETYPE *arg)
	{
		*arg = (D3DPRIMITIVETYPE) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DPRIMITIVETYPE arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(UINT *arg)
	{
		*arg = (UINT) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(UINT arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(INT *arg)
	{
		*arg = (INT) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(INT arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DVertexBuffer9 **arg)
	{
		*arg = (IDirect3DVertexBuffer9 *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DVertexBuffer9 *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DVertexDeclaration9 **arg)
	{
		*arg = (IDirect3DVertexDeclaration9 *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DVertexDeclaration9 *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DIndexBuffer9 **arg)
	{
		*arg = (IDirect3DIndexBuffer9 *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DIndexBuffer9 *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DSurface9 **arg)
	{
		*arg = (IDirect3DSurface9 *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DSurface9 *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(DWORD *arg)
	{
		*arg = (DWORD) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(DWORD arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DSwapChain9 ***arg)
	{
		*arg = (IDirect3DSwapChain9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DSwapChain9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(HWND *arg)
	{
		*arg = (HWND) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(HWND arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DBACKBUFFER_TYPE *arg)
	{
		*arg = (D3DBACKBUFFER_TYPE) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DBACKBUFFER_TYPE arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DSurface9 ***arg)
	{
		*arg = (IDirect3DSurface9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DSurface9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DFORMAT *arg)
	{
		*arg = (D3DFORMAT) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DFORMAT arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DPOOL *arg)
	{
		*arg = (D3DPOOL) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DPOOL arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DTexture9 ***arg)
	{
		*arg = (IDirect3DTexture9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DTexture9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DVolumeTexture9 ***arg)
	{
		*arg = (IDirect3DVolumeTexture9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DVolumeTexture9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DCubeTexture9 ***arg)
	{
		*arg = (IDirect3DCubeTexture9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DCubeTexture9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DVertexBuffer9 ***arg)
	{
		*arg = (IDirect3DVertexBuffer9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DVertexBuffer9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DIndexBuffer9 ***arg)
	{
		*arg = (IDirect3DIndexBuffer9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DIndexBuffer9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DMULTISAMPLE_TYPE *arg)
	{
		*arg = (D3DMULTISAMPLE_TYPE) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DMULTISAMPLE_TYPE arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DBaseTexture9 **arg)
	{
		*arg = (IDirect3DBaseTexture9 *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DBaseTexture9 *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DTEXTUREFILTERTYPE *arg)
	{
		*arg = (D3DTEXTUREFILTERTYPE) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DTEXTUREFILTERTYPE arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(float *arg)
	{
		*arg = (float) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(float arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DTRANSFORMSTATETYPE *arg)
	{
		*arg = (D3DTRANSFORMSTATETYPE) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DTRANSFORMSTATETYPE arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DRENDERSTATETYPE *arg)
	{
		*arg = (D3DRENDERSTATETYPE) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DRENDERSTATETYPE arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DSTATEBLOCKTYPE *arg)
	{
		*arg = (D3DSTATEBLOCKTYPE) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DSTATEBLOCKTYPE arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DStateBlock9 ***arg)
	{
		*arg = (IDirect3DStateBlock9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DStateBlock9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DBaseTexture9 ***arg)
	{
		*arg = (IDirect3DBaseTexture9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DBaseTexture9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DTEXTURESTAGESTATETYPE *arg)
	{
		*arg = (D3DTEXTURESTAGESTATETYPE) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DTEXTURESTAGESTATETYPE arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DSAMPLERSTATETYPE *arg)
	{
		*arg = (D3DSAMPLERSTATETYPE) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DSAMPLERSTATETYPE arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DVertexDeclaration9 ***arg)
	{
		*arg = (IDirect3DVertexDeclaration9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DVertexDeclaration9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DVertexShader9 ***arg)
	{
		*arg = (IDirect3DVertexShader9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DVertexShader9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DVertexShader9 **arg)
	{
		*arg = (IDirect3DVertexShader9 *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DVertexShader9 *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DPixelShader9 ***arg)
	{
		*arg = (IDirect3DPixelShader9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DPixelShader9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DPixelShader9 **arg)
	{
		*arg = (IDirect3DPixelShader9 *) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DPixelShader9 *arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(D3DQUERYTYPE *arg)
	{
		*arg = (D3DQUERYTYPE) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(D3DQUERYTYPE arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3DQuery9 ***arg)
	{
		*arg = (IDirect3DQuery9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3DQuery9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void GetDWORD(IDirect3D9 ***arg)
	{
		*arg = (IDirect3D9 **) DoGetDWORD();
	}

	/* =================================================================================================================
	 =================================================================================================================== */
	void PutDWORD(IDirect3D9 **arg)
	{
		DoPutDWORD((DWORD) arg);
	};

	// =================================================================================================================
	//    Get the unread or unwritten meory size
	// =================================================================================================================
	int GetAvailableMemorySize()
	{
		int ret = (m_iSize - (m_pNext - m_pMem));
		return ret;
	}

	// =================================================================================================================
	//    check if there is iSize DWORDs left
	// =================================================================================================================
	bool CheckAvailableMemorySize(int iSize)
	{
		int AvailableMemory = GetAvailableMemorySize();
		;
		return(iSize <= AvailableMemory);
	}

	// pointer to memory given to us by app
	DWORD	*m_pMem;

	// size of memory in DWORDs.
	UINT	m_iSize;

	// pointer to current token position in memory
	DWORD	*m_pNext;
};	// class CBMemoryBuffer

// =====================================================================================================================
//    Inline Functions
// =====================================================================================================================
inline DWORD *CBMemoryBuffer::DoGetDWORDPTR()
{
	return m_pNext;
}

/* =====================================================================================================================
 ======================================================================================================================= */
inline DWORD CBMemoryBuffer::DoGetDWORD()
{
	assert(m_pNext >= m_pMem);
	assert(m_pNext < (m_pMem + m_iSize));

	DWORD	ret = *m_pNext;
	m_pNext++;
	;;
	return ret;
}

/* =====================================================================================================================
 ======================================================================================================================= */
inline DWORD *CBMemoryBuffer::DoGetMem(DWORD memsize)
{
	int memsize_in_DWORDs = (memsize + 3) / 4;	// Number of DWORDs required to store memsize, round up
	assert(m_pNext >= m_pMem);
	assert((m_pNext + memsize_in_DWORDs - 1) < (m_pMem + m_iSize));

	DWORD	val = *m_pNext;
	m_pNext++;

	DWORD	*ret = m_pNext;
	if(val != 0)
	{
		m_pNext += memsize_in_DWORDs;
	}
	else
	{
		ret = NULL;
	}

	;;
	return ret;
}

// =====================================================================================================================
//    EMERGENT GAME TECHNOLOGIES PROPRIETARY INFORMATION This software is supplied under the terms of a license agreement
//    or nondisclosure agreement with Emergent Game Technologies and may not be copied or disclosed except in accordance
//    with the terms of that agreement. Copyright (c) 1996-2008 Emergent Game Technologies. All Rights Reserved. Emergent
//    Game Technologies, Chapel Hill, North Carolina 27517 http://www.emergent.net
// =====================================================================================================================
class	CBPlayer9
{
/* ---------------------------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------------------------------- */
public:
	CBPlayer9();
	void			Playback(IDirect3DDevice9 *pDevice, CBMemoryBuffer *pCB);
	static DWORD	PlaybackNumberArgs[215];
	void			DoNULLCall();
	void			DoQueryInterface();
	void			DoAddRef();
	void			DoRelease();

	/*
	 * Implemnted IDirect3DDevice9 methods ;
	 * Note that it is assumed that input values will be valid a record time. ;
	 * Also there is no mechnism to retain returned values during playback
	 */
	void			DoDrawPrimitive();
	void			DoDrawIndexedPrimitive();
	void			DoSetStreamSource();
	void			DoSetStreamSourceFreq();
	void			DoSetVertexDeclaration();
	void			DoSetIndices();
	void			DoTestCooperativeLevel();
	void			DoEvictManagedResources();
	void			DoBeginScene();
	void			DoEndScene();
	void			DoBeginStateBlock();
	void			DoSetCursorProperties();
	void			DoSetCursorPosition();
	void			DoSetDialogBoxMode();
	void			DoReset();
	void			DoPresent();
	void			DoSetGammaRamp();
	void			DoUpdateSurface();
	void			DoUpdateTexture();
	void			DoStretchRect();
	void			DoColorFill();
	void			DoSetRenderTarget();
	void			DoSetDepthStencilSurface();
	void			DoClear();
	void			DoSetTransform();
	void			DoMultiplyTransform();
	void			DoSetViewport();
	void			DoSetMaterial();
	void			DoLightEnable();
	void			DoSetClipPlane();
	void			DoSetRenderState();
	void			DoEndStateBlock();
	void			DoSetClipStatus();
	void			DoSetTexture();
	void			DoSetTextureStageState();
	void			DoSetSamplerState();
	void			DoValidateDevice();
	void			DoSetPaletteEntries();
	void			DoSetCurrentTexturePalette();
	void			DoSetScissorRect();
	void			DoSetSoftwareVertexProcessing();
	void			DoSetNPatchMode();
	void			DoDrawPrimitiveUP();
	void			DoDrawIndexedPrimitiveUP();
	void			DoProcessVertices();
	void			DoSetFVF();
	void			DoSetVertexShader();
	void			DoSetPixelShader();
	void			DoDrawRectPatch();
	void			DoDrawTriPatch();
	void			DoDeletePatch();
	void			DoSetLight();
	void			DoSetVertexShaderConstantF();
	void			DoSetVertexShaderConstantI();
	void			DoSetVertexShaderConstantB();
	void			DoSetPixelShaderConstantF();
	void			DoSetPixelShaderConstantI();
	void			DoSetPixelShaderConstantB();

	/* =================================================================================================================
	    IDirect3DDevice methods that cannot be recorded which throw errors ;
	    create methods should not be recorded.
	 =================================================================================================================== */
	void DoCreateOffscreenPlainSurface()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateStateBlock()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateAdditionalSwapChain()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateVertexDeclaration()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateVertexShader()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateQuery()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateTexture()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateVolumeTexture()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateCubeTexture()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateVertexBuffer()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateIndexBuffer()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateRenderTarget()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreateDepthStencilSurface()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	// =================================================================================================================
	//    get methods should not be recorded.
	// =================================================================================================================
	void DoGetTextureStageState()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetSwapChain()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetRenderTargetData()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetGammaRamp()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetFrontBufferData()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetBackBuffer()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetRasterStatus()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetRenderTarget()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetDeviceCaps()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetDisplayMode()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetCreationParameters()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetDepthStencilSurface()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetTransform()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetViewport()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetMaterial()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetLight()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetLightEnable()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetClipPlane()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetRenderState()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetClipStatus()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetTexture()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetSamplerState()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetPaletteEntries()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetCurrentTexturePalette()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetScissorRect()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetVertexDeclaration()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetFVF()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetVertexShader()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetStreamSource()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetStreamSourceFreq()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetIndices()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetDirect3D()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetVertexShaderConstantF()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetVertexShaderConstantI()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetVertexShaderConstantB()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetPixelShaderConstantF()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetPixelShaderConstantI()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetPixelShaderConstantB()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoGetPixelShader()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* =================================================================================================================
	 =================================================================================================================== */
	void DoCreatePixelShader()
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return;
	};

	/* IDirect3DDevice methods that cannot be recorded which throw errors */
	STDMETHOD_ (UINT, GetAvailableTextureMem) (THIS)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return 0;
	};
	STDMETHOD_ (UINT, GetNumberOfSwapChains) (THIS)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return 0;
	};
	STDMETHOD_ (BOOL, ShowCursor) (BOOL bShow)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return FALSE;
	};
	STDMETHOD_ (BOOL, GetSoftwareVertexProcessing) (THIS)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return FALSE;
	};
	STDMETHOD_ (float, GetNPatchMode) (THIS)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return 0.0f;
	};
	STDMETHOD (GetVertexShaderConstantF) (UINT StartRegister, float *pConstantData, UINT Vector4fCount)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return D3DERR_INVALIDCALL;
	};
	STDMETHOD (GetVertexShaderConstantI) (UINT StartRegister, int *pConstantData, UINT Vector4iCount)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return D3DERR_INVALIDCALL;
	};
	STDMETHOD (GetVertexShaderConstantB) (UINT StartRegister, BOOL * pConstantData, UINT BoolCount)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return D3DERR_INVALIDCALL;
	};
	STDMETHOD (GetPixelShaderConstantF) (UINT StartRegister, float *pConstantData, UINT Vector4fCount)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return D3DERR_INVALIDCALL;
	};
	STDMETHOD (GetPixelShaderConstantI) (UINT StartRegister, int *pConstantData, UINT Vector4iCount)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return D3DERR_INVALIDCALL;
	};
	STDMETHOD (GetPixelShaderConstantB) (UINT StartRegister, BOOL * pConstantData, UINT BoolCount)
	{
		OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
		__debugbreak();;
		return D3DERR_INVALIDCALL;
	};
	CBMemoryBuffer		*m_pCB;
	IDirect3DDevice9	*m_pDevice;
};
typedef void (CBPlayer9:: *PlayBFuncPTR) ();

// Must access by an (enum - CBD3D_COMMANDS::NULLCALL)
PlayBFuncPTR	PlaybackFunctionTable[] =
{
	&CBPlayer9::DoNULLCall,
	&CBPlayer9::DoQueryInterface,
	&CBPlayer9::DoAddRef,
	&CBPlayer9::DoRelease,
	&CBPlayer9::DoDrawPrimitive,
	&CBPlayer9::DoDrawIndexedPrimitive,
	&CBPlayer9::DoSetStreamSource,
	&CBPlayer9::DoSetStreamSourceFreq,
	&CBPlayer9::DoSetVertexDeclaration,
	&CBPlayer9::DoSetIndices,
	&CBPlayer9::DoTestCooperativeLevel,
	&CBPlayer9::DoEvictManagedResources,
	&CBPlayer9::DoBeginScene,
	&CBPlayer9::DoEndScene,
	&CBPlayer9::DoBeginStateBlock,
	&CBPlayer9::DoSetCursorProperties,
	&CBPlayer9::DoSetCursorPosition,
	&CBPlayer9::DoSetDialogBoxMode,
	&CBPlayer9::DoGetDeviceCaps,
	&CBPlayer9::DoGetDisplayMode,
	&CBPlayer9::DoGetCreationParameters,
	&CBPlayer9::DoCreateAdditionalSwapChain,
	&CBPlayer9::DoGetSwapChain,
	&CBPlayer9::DoReset,
	&CBPlayer9::DoPresent,
	&CBPlayer9::DoGetBackBuffer,
	&CBPlayer9::DoGetRasterStatus,
	&CBPlayer9::DoSetGammaRamp,
	&CBPlayer9::DoGetGammaRamp,
	&CBPlayer9::DoCreateTexture,
	&CBPlayer9::DoCreateVolumeTexture,
	&CBPlayer9::DoCreateCubeTexture,
	&CBPlayer9::DoCreateVertexBuffer,
	&CBPlayer9::DoCreateIndexBuffer,
	&CBPlayer9::DoCreateRenderTarget,
	&CBPlayer9::DoCreateDepthStencilSurface,
	&CBPlayer9::DoUpdateSurface,
	&CBPlayer9::DoUpdateTexture,
	&CBPlayer9::DoGetRenderTargetData,
	&CBPlayer9::DoGetFrontBufferData,
	&CBPlayer9::DoStretchRect,
	&CBPlayer9::DoColorFill,
	&CBPlayer9::DoCreateOffscreenPlainSurface,
	&CBPlayer9::DoSetRenderTarget,
	&CBPlayer9::DoGetRenderTarget,
	&CBPlayer9::DoSetDepthStencilSurface,
	&CBPlayer9::DoGetDepthStencilSurface,
	&CBPlayer9::DoClear,
	&CBPlayer9::DoSetTransform,
	&CBPlayer9::DoGetTransform,
	&CBPlayer9::DoMultiplyTransform,
	&CBPlayer9::DoSetViewport,
	&CBPlayer9::DoGetViewport,
	&CBPlayer9::DoSetMaterial,
	&CBPlayer9::DoGetMaterial,
	&CBPlayer9::DoSetLight,
	&CBPlayer9::DoGetLight,
	&CBPlayer9::DoLightEnable,
	&CBPlayer9::DoGetLightEnable,
	&CBPlayer9::DoSetClipPlane,
	&CBPlayer9::DoGetClipPlane,
	&CBPlayer9::DoSetRenderState,
	&CBPlayer9::DoGetRenderState,
	&CBPlayer9::DoCreateStateBlock,
	&CBPlayer9::DoEndStateBlock,
	&CBPlayer9::DoSetClipStatus,
	&CBPlayer9::DoGetClipStatus,
	&CBPlayer9::DoGetTexture,
	&CBPlayer9::DoSetTexture,
	&CBPlayer9::DoGetTextureStageState,
	&CBPlayer9::DoSetTextureStageState,
	&CBPlayer9::DoGetSamplerState,
	&CBPlayer9::DoSetSamplerState,
	&CBPlayer9::DoValidateDevice,
	&CBPlayer9::DoSetPaletteEntries,
	&CBPlayer9::DoGetPaletteEntries,
	&CBPlayer9::DoSetCurrentTexturePalette,
	&CBPlayer9::DoGetCurrentTexturePalette,
	&CBPlayer9::DoSetScissorRect,
	&CBPlayer9::DoGetScissorRect,
	&CBPlayer9::DoSetSoftwareVertexProcessing,
	&CBPlayer9::DoSetNPatchMode,
	&CBPlayer9::DoDrawPrimitiveUP,
	&CBPlayer9::DoDrawIndexedPrimitiveUP,
	&CBPlayer9::DoProcessVertices,
	&CBPlayer9::DoCreateVertexDeclaration,
	&CBPlayer9::DoGetVertexDeclaration,
	&CBPlayer9::DoSetFVF,
	&CBPlayer9::DoGetFVF,
	&CBPlayer9::DoCreateVertexShader,
	&CBPlayer9::DoSetVertexShader,
	&CBPlayer9::DoGetVertexShader,
	&CBPlayer9::DoSetVertexShaderConstantF,
	&CBPlayer9::DoGetVertexShaderConstantF,
	&CBPlayer9::DoSetVertexShaderConstantI,
	&CBPlayer9::DoGetVertexShaderConstantI,
	&CBPlayer9::DoSetVertexShaderConstantB,
	&CBPlayer9::DoGetVertexShaderConstantB,
	&CBPlayer9::DoGetStreamSource,
	&CBPlayer9::DoGetStreamSourceFreq,
	&CBPlayer9::DoGetIndices,
	&CBPlayer9::DoCreatePixelShader,
	&CBPlayer9::DoSetPixelShader,
	&CBPlayer9::DoGetPixelShader,
	&CBPlayer9::DoSetPixelShaderConstantF,
	&CBPlayer9::DoGetPixelShaderConstantF,
	&CBPlayer9::DoSetPixelShaderConstantI,
	&CBPlayer9::DoGetPixelShaderConstantI,
	&CBPlayer9::DoSetPixelShaderConstantB,
	&CBPlayer9::DoGetPixelShaderConstantB,
	&CBPlayer9::DoDrawRectPatch,
	&CBPlayer9::DoDrawTriPatch,
	&CBPlayer9::DoDeletePatch,
	&CBPlayer9::DoCreateQuery,
	&CBPlayer9::DoGetDirect3D,	// Last supported func, if changed must fix CBPlayer9::Playback logic

	// not implemented
	(PlayBFuncPTR) & CBPlayer9::GetAvailableTextureMem,
	(PlayBFuncPTR) & CBPlayer9::GetNumberOfSwapChains,
	(PlayBFuncPTR) & CBPlayer9::ShowCursor,
	(PlayBFuncPTR) & CBPlayer9::GetSoftwareVertexProcessing,
	(PlayBFuncPTR) & CBPlayer9::GetNPatchMode
};

/* =====================================================================================================================
 ======================================================================================================================= */
CBPlayer9::CBPlayer9() :
	m_pCB(NULL),
	m_pDevice(NULL)
{
}

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::Playback(IDirect3DDevice9 *pDevice, CBMemoryBuffer *pCB)
{
	m_pDevice = pDevice;
	m_pCB = pCB;

	bool	target = false;
	m_pCB->ResetNext();

	DWORD	dwLastToken = 0;
	DWORD	dwLastFuncToken = 0;
	DWORD	dwInstructionCount = 0;
	bool	bParsingCommand = true;
	while(bParsingCommand && m_pCB->GetAvailableMemorySize() > 0)
	{
		DWORD	dwFunc = m_pCB->DoGetDWORD();
		if(dwFunc == CBD3D_COMMANDS::NULLCALL)
		{
			m_pCB->ResetNext();
			bParsingCommand = false;
		}
		else if(dwFunc < CBD3D_COMMANDS::NULLCALL || dwFunc > CBD3D_COMMANDS::GetDirect3D)
		{
			// this allows you to recover from buffer corruption.
			m_pCB->ResetNext();
			bParsingCommand = false;

			// OutputDebugStringA(__FUNCTION__ ": Invalid function token in command buffer,
			// buffer must be corrupt\n");
			// CBD3D_BREAK();
		}
		else
		{
			target = false;

			static bool bGo = false;
			if(bGo && dwFunc == CBD3D_COMMANDS::SetTextureStageState)
			{
				target = true;

				char	temp[300];
				DWORD	*pNext = m_pCB->DoGetDWORDPTR();
				sprintf_s
				(
					temp,
					299,
					"%s  ( %d %d %d ) \n",
					CBMemoryBuffer::Index2FunctionName(dwFunc),
					pNext[0],
					pNext[2],
					pNext[3]
				);
				OutputDebugStringA(temp);
			}
			(this->*PlaybackFunctionTable[dwFunc - CBD3D_COMMANDS::NULLCALL]) ();
			dwLastFuncToken = dwFunc;
		}

		dwLastToken = dwFunc;
		dwInstructionCount++;
	}

	m_pDevice = NULL;
	m_pCB = NULL;
}

// =====================================================================================================================
//    The functions below are helpers that use the STDPLAYFUNC macros.;
// =====================================================================================================================
void CBPlayer9::DoNULLCall()
{
	OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
	__debugbreak();;
	return;
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoQueryInterface()
{
	OutputDebugStringA("CBD3D: " __FUNCTION__ " not implemented via command buffers.\n");
	__debugbreak();;
	return;
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoAddRef()
{ ;
	if(FAILED(m_pDevice->AddRef())) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoRelease()
{ ;
	if(FAILED(m_pDevice->Release())) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoDrawPrimitive()
{ ;
	D3DPRIMITIVETYPE	arg1;
	m_pCB->GetDWORD(&arg1);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	UINT	arg3;
	m_pCB->GetDWORD(&arg3);
	if(FAILED(m_pDevice->DrawPrimitive(arg1, arg2, arg3))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoDrawIndexedPrimitive()
{ ;
	D3DPRIMITIVETYPE	arg1;
	m_pCB->GetDWORD(&arg1);

	INT arg2;
	m_pCB->GetDWORD(&arg2);

	UINT	arg3;
	m_pCB->GetDWORD(&arg3);

	UINT	arg4;
	m_pCB->GetDWORD(&arg4);

	UINT	arg5;
	m_pCB->GetDWORD(&arg5);

	UINT	arg6;
	m_pCB->GetDWORD(&arg6);
	if(FAILED(m_pDevice->DrawIndexedPrimitive(arg1, arg2, arg3, arg4, arg5, arg6)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetStreamSource()
{ ;
	UINT	arg1;
	m_pCB->GetDWORD(&arg1);

	IDirect3DVertexBuffer9	*arg2;
	m_pCB->GetDWORD(&arg2);

	UINT	arg3;
	m_pCB->GetDWORD(&arg3);

	UINT	arg4;
	m_pCB->GetDWORD(&arg4);
	if(FAILED(m_pDevice->SetStreamSource(arg1, arg2, arg3, arg4)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetStreamSourceFreq()
{ ;
	UINT	arg1;
	m_pCB->GetDWORD(&arg1);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->SetStreamSourceFreq(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetVertexDeclaration()
{ ;
	IDirect3DVertexDeclaration9 *arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetVertexDeclaration(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetIndices()
{ ;
	IDirect3DIndexBuffer9	*arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetIndices(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoTestCooperativeLevel()
{ ;
	if(FAILED(m_pDevice->TestCooperativeLevel())) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoEvictManagedResources()
{ ;
	if(FAILED(m_pDevice->EvictManagedResources())) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoBeginScene()
{ ;
	if(FAILED(m_pDevice->BeginScene())) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoEndScene()
{ ;
	if(FAILED(m_pDevice->EndScene())) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoBeginStateBlock()
{ ;
	if(FAILED(m_pDevice->BeginStateBlock())) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetCursorProperties()
{ ;
	UINT	arg1;
	m_pCB->GetDWORD(&arg1);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	IDirect3DSurface9	*arg3;
	m_pCB->GetDWORD(&arg3);
	if(FAILED(m_pDevice->SetCursorProperties(arg1, arg2, arg3)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetCursorPosition()
{ ;
	int arg1;
	m_pCB->GetDWORD(&arg1);

	int arg2;
	m_pCB->GetDWORD(&arg2);

	DWORD	arg3;
	m_pCB->GetDWORD(&arg3);
	m_pDevice->SetCursorPosition(arg1, arg2, arg3);
}

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetDialogBoxMode()
{ ;
	BOOL	arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetDialogBoxMode(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoReset()
{ ;
	D3DPRESENT_PARAMETERS	*arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->Reset(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoPresent()
{ ;
	CONST RECT	*arg1;
	m_pCB->GetDWORD(&arg1);

	CONST RECT	*arg2;
	m_pCB->GetDWORD(&arg2);

	HWND	arg3;
	m_pCB->GetDWORD(&arg3);

	CONST RGNDATA	*arg4;
	m_pCB->GetDWORD(&arg4);
	if(FAILED(m_pDevice->Present(arg1, arg2, arg3, arg4))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetGammaRamp()
{ ;
	UINT	arg1;
	m_pCB->GetDWORD(&arg1);

	DWORD	arg2;
	m_pCB->GetDWORD(&arg2);

	CONST D3DGAMMARAMP	*arg3;
	m_pCB->GetDWORD(&arg3);
	m_pDevice->SetGammaRamp(arg1, arg2, arg3);
}

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoUpdateSurface()
{ ;
	IDirect3DSurface9	*arg1;
	m_pCB->GetDWORD(&arg1);

	CONST RECT	*arg2;
	m_pCB->GetDWORD(&arg2);

	IDirect3DSurface9	*arg3;
	m_pCB->GetDWORD(&arg3);

	CONST POINT *arg4;
	m_pCB->GetDWORD(&arg4);
	if(FAILED(m_pDevice->UpdateSurface(arg1, arg2, arg3, arg4)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoUpdateTexture()
{ ;
	IDirect3DBaseTexture9	*arg1;
	m_pCB->GetDWORD(&arg1);

	IDirect3DBaseTexture9	*arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->UpdateTexture(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoStretchRect()
{ ;
	IDirect3DSurface9	*arg1;
	m_pCB->GetDWORD(&arg1);

	CONST RECT	*arg2;
	m_pCB->GetDWORD(&arg2);

	IDirect3DSurface9	*arg3;
	m_pCB->GetDWORD(&arg3);

	CONST RECT	*arg4;
	m_pCB->GetDWORD(&arg4);

	D3DTEXTUREFILTERTYPE	arg5;
	m_pCB->GetDWORD(&arg5);
	if(FAILED(m_pDevice->StretchRect(arg1, arg2, arg3, arg4, arg5)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoColorFill()
{ ;
	IDirect3DSurface9	*arg1;
	m_pCB->GetDWORD(&arg1);

	CONST RECT	*arg2;
	m_pCB->GetDWORD(&arg2);

	D3DCOLOR	arg3;
	m_pCB->GetDWORD(&arg3);
	if(FAILED(m_pDevice->ColorFill(arg1, arg2, arg3))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetRenderTarget()
{ ;
	DWORD	arg1;
	m_pCB->GetDWORD(&arg1);

	IDirect3DSurface9	*arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->SetRenderTarget(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetDepthStencilSurface()
{ ;
	IDirect3DSurface9	*arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetDepthStencilSurface(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoClear()
{ ;
	DWORD	arg1;
	m_pCB->GetDWORD(&arg1);

	CONST D3DRECT	*arg2;
	m_pCB->GetDWORD(&arg2);

	DWORD	arg3;
	m_pCB->GetDWORD(&arg3);

	D3DCOLOR	arg4;
	m_pCB->GetDWORD(&arg4);

	float	arg5;
	m_pCB->GetDWORD(&arg5);

	DWORD	arg6;
	m_pCB->GetDWORD(&arg6);
	if(FAILED(m_pDevice->Clear(arg1, arg2, arg3, arg4, arg5, arg6)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetTransform()
{ ;
	D3DTRANSFORMSTATETYPE	arg1;
	m_pCB->GetDWORD(&arg1);

	CONST D3DMATRIX *arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->SetTransform(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoMultiplyTransform()
{ ;
	D3DTRANSFORMSTATETYPE	arg1;
	m_pCB->GetDWORD(&arg1);

	CONST D3DMATRIX *arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->MultiplyTransform(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetViewport()
{ ;
	CONST D3DVIEWPORT9	*arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetViewport(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetMaterial()
{ ;
	CONST D3DMATERIAL9	*arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetMaterial(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetLight()
{ ;
	DWORD	arg1;
	m_pCB->GetDWORD(&arg1);

	CONST D3DLIGHT9 *arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->SetLight(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoLightEnable()
{ ;
	DWORD	arg1;
	m_pCB->GetDWORD(&arg1);

	BOOL	arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->LightEnable(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetClipPlane()
{ ;
	DWORD	arg1;
	m_pCB->GetDWORD(&arg1);

	CONST float *arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->SetClipPlane(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetRenderState()
{ ;
	D3DRENDERSTATETYPE	arg1;
	m_pCB->GetDWORD(&arg1);

	DWORD	arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->SetRenderState(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoEndStateBlock()
{ ;
	IDirect3DStateBlock9	**arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->EndStateBlock(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetClipStatus()
{ ;
	CONST D3DCLIPSTATUS9	*arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetClipStatus(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetTexture()
{ ;
	DWORD	arg1;
	m_pCB->GetDWORD(&arg1);

	IDirect3DBaseTexture9	*arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->SetTexture(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetTextureStageState()
{ ;
	DWORD	arg1;
	m_pCB->GetDWORD(&arg1);

	D3DTEXTURESTAGESTATETYPE	arg2;
	m_pCB->GetDWORD(&arg2);

	DWORD	arg3;
	m_pCB->GetDWORD(&arg3);
	if(FAILED(m_pDevice->SetTextureStageState(arg1, arg2, arg3)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetSamplerState()
{ ;
	DWORD	arg1;
	m_pCB->GetDWORD(&arg1);

	D3DSAMPLERSTATETYPE arg2;
	m_pCB->GetDWORD(&arg2);

	DWORD	arg3;
	m_pCB->GetDWORD(&arg3);
	if(FAILED(m_pDevice->SetSamplerState(arg1, arg2, arg3))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoValidateDevice()
{ ;
	DWORD	*arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->ValidateDevice(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetPaletteEntries()
{ ;
	UINT	arg1;
	m_pCB->GetDWORD(&arg1);

	CONST PALETTEENTRY	*arg2;
	m_pCB->GetDWORD(&arg2);
	if(FAILED(m_pDevice->SetPaletteEntries(arg1, arg2))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetCurrentTexturePalette()
{ ;
	UINT	arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetCurrentTexturePalette(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetScissorRect()
{ ;
	CONST RECT	*arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetScissorRect(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetSoftwareVertexProcessing()
{ ;
	BOOL	arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetSoftwareVertexProcessing(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetNPatchMode()
{ ;
	float	arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetNPatchMode(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoDrawPrimitiveUP()
{ ;
	D3DPRIMITIVETYPE	arg1;
	m_pCB->GetDWORD(&arg1);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	CONST void	*arg3;
	m_pCB->GetDWORD(&arg3);

	UINT	arg4;
	m_pCB->GetDWORD(&arg4);
	if(FAILED(m_pDevice->DrawPrimitiveUP(arg1, arg2, arg3, arg4)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoDrawIndexedPrimitiveUP()
{ ;
	D3DPRIMITIVETYPE	arg1;
	m_pCB->GetDWORD(&arg1);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	UINT	arg3;
	m_pCB->GetDWORD(&arg3);

	UINT	arg4;
	m_pCB->GetDWORD(&arg4);

	CONST void	*arg5;
	m_pCB->GetDWORD(&arg5);

	D3DFORMAT	arg6;
	m_pCB->GetDWORD(&arg6);

	CONST void	*arg7;
	m_pCB->GetDWORD(&arg7);

	UINT	arg8;
	m_pCB->GetDWORD(&arg8);
	if(FAILED(m_pDevice->DrawIndexedPrimitiveUP(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoProcessVertices()
{ ;
	UINT	arg1;
	m_pCB->GetDWORD(&arg1);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	UINT	arg3;
	m_pCB->GetDWORD(&arg3);

	IDirect3DVertexBuffer9	*arg4;
	m_pCB->GetDWORD(&arg4);

	IDirect3DVertexDeclaration9 *arg5;
	m_pCB->GetDWORD(&arg5);

	DWORD	arg6;
	m_pCB->GetDWORD(&arg6);
	if(FAILED(m_pDevice->ProcessVertices(arg1, arg2, arg3, arg4, arg5, arg6)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetFVF()
{ ;
	DWORD	arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetFVF(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetVertexShader()
{ ;
	IDirect3DVertexShader9	*arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetVertexShader(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetPixelShader()
{ ;
	IDirect3DPixelShader9	*arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->SetPixelShader(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoDrawRectPatch()
{ ;
	UINT	arg1;
	m_pCB->GetDWORD(&arg1);

	CONST float *arg2;
	m_pCB->GetDWORD(&arg2);

	CONST D3DRECTPATCH_INFO *arg3;
	m_pCB->GetDWORD(&arg3);
	if(FAILED(m_pDevice->DrawRectPatch(arg1, arg2, arg3))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoDrawTriPatch()
{ ;
	UINT	arg1;
	m_pCB->GetDWORD(&arg1);

	CONST float *arg2;
	m_pCB->GetDWORD(&arg2);

	CONST D3DTRIPATCH_INFO	*arg3;
	m_pCB->GetDWORD(&arg3);
	if(FAILED(m_pDevice->DrawTriPatch(arg1, arg2, arg3))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoDeletePatch()
{ ;
	UINT	arg1;
	m_pCB->GetDWORD(&arg1);
	if(FAILED(m_pDevice->DeletePatch(arg1))) OutputDebugStringA(__FUNCTION__ " failed in playback\n");
};

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetVertexShaderConstantF()
{
	UINT	arg0;
	m_pCB->GetDWORD(&arg0);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	int			iSize = arg2 * 4 * sizeof(float);
	CONST float *arg1 = (CONST float *) m_pCB->DoGetMem(iSize);
	if(FAILED(m_pDevice->SetVertexShaderConstantF(arg0, arg1, arg2)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
}

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetVertexShaderConstantI()
{
	UINT	arg0;
	m_pCB->GetDWORD(&arg0);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	int			iSize = arg2 * 4 * sizeof(int);
	CONST int	*arg1 = (CONST int *) m_pCB->DoGetMem(iSize);
	if(FAILED(m_pDevice->SetVertexShaderConstantI(arg0, arg1, arg2)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
}

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetVertexShaderConstantB()
{
	UINT	arg0;
	m_pCB->GetDWORD(&arg0);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	int			iSize = arg2 * 4 * sizeof(BOOL);
	CONST BOOL	*arg1 = (CONST BOOL *) m_pCB->DoGetMem(iSize);
	if(FAILED(m_pDevice->SetVertexShaderConstantB(arg0, arg1, arg2)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
}

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetPixelShaderConstantF()
{
	UINT	arg0;
	m_pCB->GetDWORD(&arg0);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	int			iSize = arg2 * 4 * sizeof(float);
	CONST float *arg1 = (CONST float *) m_pCB->DoGetMem(iSize);
	if(FAILED(m_pDevice->SetPixelShaderConstantF(arg0, arg1, arg2)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
}

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetPixelShaderConstantI()
{
	UINT	arg0;
	m_pCB->GetDWORD(&arg0);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	int			iSize = arg2 * 4 * sizeof(int);
	CONST int	*arg1 = (CONST int *) m_pCB->DoGetMem(iSize);
	if(FAILED(m_pDevice->SetPixelShaderConstantI(arg0, arg1, arg2)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
}

/* =====================================================================================================================
 ======================================================================================================================= */
void CBPlayer9::DoSetPixelShaderConstantB()
{
	UINT	arg0;
	m_pCB->GetDWORD(&arg0);

	UINT	arg2;
	m_pCB->GetDWORD(&arg2);

	int			iSize = arg2 * 4 * sizeof(BOOL);
	CONST BOOL	*arg1 = (CONST BOOL *) m_pCB->DoGetMem(iSize);
	if(FAILED(m_pDevice->SetPixelShaderConstantB(arg0, arg1, arg2)))
		OutputDebugStringA(__FUNCTION__ " failed in playback\n");
}
